package com.doupi.partner.constant;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 商家状态
 * 
 * @author Alvin Wang
 * @version 1.0.0 @ 2017-04-17
 */
public enum BusinessStatusEnum {
	INIT("初始", Byte.valueOf("0")),

	REPORT("报备", Byte.valueOf("1")),

	SIGNED("已签约", Byte.valueOf("2")),

	PAID("已缴费", Byte.valueOf("3")),

	EXPIRE("到期", Byte.valueOf("97")),

	ON_SHELF("上架", Byte.valueOf("98")),

	OFF_SHELF("下架", Byte.valueOf("99"));

	private String name;
	private byte code;

	BusinessStatusEnum(String name, byte code) {
		this.name = name;
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public byte getCode() {
		return code;
	}

	/**
	 * 根据 code获取{@link BusinessStatusEnum}
	 *
	 * @param code
	 *            code
	 * @return {@link BusinessStatusEnum}
	 */
	public static BusinessStatusEnum getBusinessStatusByCode(byte code) {
		for (BusinessStatusEnum businessStatus : values()) {
			if (code == businessStatus.code) {
				return businessStatus;
			}
		}
		return null;
	}

	/**
	 * 获取所有{@link BusinessStatusEnum}
	 *
	 * @return list {@link BusinessStatusEnum}
	 */
	public static List<BusinessStatusEnum> getAllBusinessStatus() {
		List<BusinessStatusEnum> list = new ArrayList<>();
		Collections.addAll(list, values());
		return list;
	}
}
